#ifndef AER_VERTEXARRAY_HPP_
#define AER_VERTEXARRAY_HPP_

#include "aerDeviceResource.hpp"


namespace aer {
  
class VertexArray : public DeviceResource
{    
  public:
    void generate() 
    {
      AER_ASSERT( !isGenerated() ); 
      glGenVertexArrays( 1, &m_id); 
    }
    
    void release()
    { 
      if (isGenerated()) {
        glDeleteVertexArrays( 1, &m_id); 
        m_id = 0u;
      }
    }
      
    void bind() const
    {
      AER_ASSERT( isGenerated() );
      glBindVertexArray( m_id ); 
    }
    
    static void unbind()
    { 
      glBindVertexArray(0u); 
    }
};
  
} // aer

#endif // AER_VERTEXARRAY_HPP_
